-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix transaction.set() failure without retry on "already-exists" error #6729
Fix transaction.set() failure without retry on "already-exists" error #6729
Conversation
🦋 Changeset detectedLatest commit: d93d965 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just two very minor comments!
|
||
if (retryCounter === 1) { | ||
expect(snap1.exists()).to.be.false; | ||
// On the first attemp, create a doc before transaction.set(), so that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "attemp" -> "attempt"
transaction.set(docRef, { count: 2 }); | ||
}); | ||
expect(retryCounter).to.equal(2); | ||
const result = await getDoc(docRef); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please rename result
to snapshot
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Problem
Transaction.get(ref) followed by transaction.set(ref, {...}) is causing the transaction to fail with error 'Document already exists' if the document was created by another app between the get and set.
Cause
'already-exists' is considered to be a permanent error for transactions, therefore will not be retried.
firebase-js-sdk/packages/firestore/src/core/transaction_runner.ts
Line 115 in f86f7de
Fix Issue: #6659